package com.itheima.article.controller;


import com.itheima.article.pojo.ApArticle;
import com.itheima.article.service.ApArticleService;
import com.itheima.article.vo.ArticleInfoVo;
import com.itheima.common.vo.ResultVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.itheima.core.controller.AbstractCoreController;

import java.util.Map;

/**
 * @description <p>已发布的文章信息</p>
 *
 * @version 1.0
 * @package com.itheima.article.controller
 */
@Api(value="ApArticleController",tags = "已发布的文章信息")
@RestController
@RequestMapping("/article")
public class ApArticleController extends AbstractCoreController<ApArticle> {

    private ApArticleService apArticleService;

    @Autowired
    public ApArticleController(ApArticleService apArticleService) {
        super(apArticleService);
        this.apArticleService=apArticleService;
    }

    /**
     * 查询文章数据，文章内容，文章配置，封装为vo返回给前端
     * @param map 接收文章id
     * @return 返回封装的vo给前端
     */
    @ApiOperation("封装文章内容接口")
    @PostMapping("/load_article_info")
    public ResultVo loadArticleInfo(@RequestBody Map<String,Long> map){
        //获取文章id
        Long articleId = map.get("articleId");
        ArticleInfoVo articleInfoVo = apArticleService.findArticleInfoVo(articleId);
        return ResultVo.ok(articleInfoVo);
    }

}

